//////////////////////////////////////////////////////////////////////////////////////////////////// // // // Ebrahim Foulaadvand 24 August 2011 // // // // This code gives the few first eigen values/eigenvectors for the time-independent Schroedinger // // equation for an infinite square well by the shooting method. // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////// #pragma hdrstop #include #include #include #include #include #include #include #include #include #include using namespace std; main(){ int i,N=100,exit; double m=1.0,hbar=1.0,a=1.,E=4.9,delx,cutoff,delE=0.001,precision=0.01,terminatedphi,phiRboundary; ofstream file1 ("V.plt"); ofstream file2 ("PsiR E=40.93.plt"); ofstream file3 ("PsiL E=40.93.plt"); ofstream file4 ("PsiR E=6.55.plt"); ofstream file5 ("PsiL E=6.55.plt"); ofstream file6 ("PsiR E=6.65.plt"); ofstream file7 ("PsiL E=6.65.plt"); ofstream file8 ("Ground stateL.plt"); ofstream file9 ("Ground stateR.plt"); delx=a/double(N); cout<<"delx= "< V(N+1,0),phi(N+1,0); //phi[0]=1; // for even eigenstates (zero derivative at x=0) therefore phi[-1]=phi[0]; phi[0]=0; // We consider odd eigenstates phi[1]=1*delx; // for odd states //cutoff=5*phi[0]; //even states cutoff=5*phi[1]; //odd states for (int i=0;i<=N;i++) { V[i]=0.; } phiRboundary=2*precision; while (fabs(phiRboundary)>precision){ terminatedphi=phi[0]; exit=0; i=0; //phi[1]=2*phi[0]- phi[0] + 2*m*(delx/hbar)*phi[0]*(delx/hbar)*(V[0]-E); // for even states phi[1]=1*delx; // for odd states while (i